package com.dal;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.model.ProductType;
import com.util.DataUtil;

public class ProductTypeDAO {
	public ArrayList<ProductType> select() {
		ArrayList<ProductType> list = new ArrayList<ProductType>();
		Connection conn = DataUtil.getConnection();
		try {
			CallableStatement stmt = conn
					.prepareCall("{ Call usp_dms_ProductTypeSelect }");
			ResultSet rs = DataUtil.executeStore(stmt);
			// Gets entities from resultset
			while (rs.next()) {
				ProductType entity = new ProductType(rs.getInt("ProductType_Id"), rs
						.getString("ProductTypeName"));
				list.add(entity);// add to list
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DataUtil.disconnected();
		}
		return (list.isEmpty()) ? null : list;
	}

	public ProductType select(int ProductTypeId) {
		return null;
	}
}
